#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<string.h>
struct Stu
{
	char name[20];
	int digits;
};
int comp_by_name(const void* p1, const void* p2)
{
	return strcmp(((struct Stu*)p1)->name, ((struct Stu*)p2)->name);
}
void swap(char* buf1,char* buf2,int size)
{
	for (int i = 0; i < size; i++) {
		int tmp = *buf1;
		*buf1 = *buf2;
		*buf2 = tmp;
		buf1++;
		buf2++;
	}
}
void bubble_sort(void* base,size_t num,size_t size,int (*pf)(const void*,const void*))
{
	for (int i = 0; i < num - 1; i++) {
		int flag = 1;
		for (int j = 0; j < num-1-i; j++) {
			if (pf((char*)base + j * size, (char*)base + (j + 1) * size) > 0) {
				swap((char*)base + j * size, (char*)base + (j + 1) * size, size);
			}
		}
	}
}
int main()
{
	struct Stu students[5] = { {"jaeigubf",82},{"uiagjh",66},{"fioadsfngf",95},{"hfsaif",88},{"iehfau",68} };
	int sz = sizeof(students) / sizeof(students[0]);
	bubble_sort(students, sz, sizeof(students[0]), comp_by_name);
	for (int i = 0; i < sz; i++) {
		printf("%s\n", students[i].name);
	}
	return 0;
}